<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Execution</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="parallel-runtime.construct.html">« parallel\Runtime::__construct</a></li>
      <li style="float: right;"><a href="parallel-runtime.close.html">parallel\Runtime::close »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.parallel-runtime.html">parallel\Runtime</a></li>
    <li>Execution</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="parallel-runtime.run" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">parallel\Runtime::run</h1>
  <p class="verinfo">(0.8.0)</p><p class="refpurpose"><span class="refname">parallel\Runtime::run</span> &mdash; <span class="dc-title">Execution</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-parallel-runtime.run-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>parallel\Runtime::run</strong></span>(<span class="methodparam"><span class="type"><a href="class.closure.html" class="type Closure">Closure</a></span> <code class="parameter">$task</code></span>): <span class="type"><span class="type">?</span><span class="type"><span class="type Future">Future</span></span></span></div>

  <p class="para rdfs-comment">
   Shall schedule <code class="parameter">task</code> for execution in parallel.
  </p>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>parallel\Runtime::run</strong></span>(<span class="methodparam"><span class="type"><a href="class.closure.html" class="type Closure">Closure</a></span> <code class="parameter">$task</code></span>, <span class="methodparam"><span class="type">array</span> <code class="parameter">$argv</code></span>): <span class="type"><span class="type">?</span><span class="type"><span class="type Future">Future</span></span></span></div>

  <p class="para rdfs-comment">
   Shall schedule <code class="parameter">task</code> for execution in parallel, passing <code class="parameter">argv</code> at execution time.
  </p>

 </div>


 <div class="refsect1 parameters" id="refsect1-parallel-runtime.run-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt>
<code class="parameter">task</code></dt>

    <dd>

     <p class="para">
      A <span class="classname"><a href="class.closure.html" class="classname">Closure</a></span> with specific characteristics.
     </p>
    </dd>

   
   
    <dt>
<code class="parameter">argv</code></dt>

    <dd>

     <p class="para">
      An <span class="type">array</span> of arguments with specific characteristics to be passed to <code class="parameter">task</code> at execution time.
     </p>
    </dd>

   
  </dl>

 </div>

 
 <div class="refsect1 closure-characteristics" id="refsect1-parallel-runtime.run-closure-characteristics">
 <h3 class="title">Task Characteristics</h3>
 <p class="para">
  Closures scheduled for parallel execution must not:
  <ul class="simplelist">
   <li class="member">accept or return by reference</li>
   <li class="member">accept or return internal objects (see notes)</li>
   <li class="member">execute a limited set of instructions</li>
  </ul>
 </p>
 <p class="para">
  Instructions prohibited in Closures intended for parallel execution are:
  <ul class="simplelist">
   <li class="member">yield</li>
   <li class="member">use by-reference</li>
   <li class="member">declare class</li>
   <li class="member">declare named function</li>
  </ul>
 </p>
 <blockquote class="note"><p><strong class="note">注意</strong>: 
  <p class="para">
   Nested closures may yield or use by-reference, but must not contain class or named function declarations.
  </p>
 </p></blockquote>
 <blockquote class="note"><p><strong class="note">注意</strong>: 
  <p class="para">
   No instructions are prohibited in the files which the task may include.
  </p>
 </p></blockquote>
 </div>

 
 <div class="refsect1 argv-characteristics" id="refsect1-parallel-runtime.run-argv-characteristics">
 <h3 class="title">Arguments Characteristics</h3>
 <p class="para">
  Arguments must not:
  <ul class="simplelist">
   <li class="member">contain references</li>
   <li class="member">contain resources</li>
   <li class="member">contain internal objects (see notes)</li>
  </ul>
  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <p class="para">
    In the case of file stream resources, the resource will be cast to the file descriptor and passed as <span class="type">int</span> where possible, this is unsupported on Windows.
   </p>
  </p></blockquote>
 </p>
 </div>


 <div class="refsect1 object-characteristics" id="refsect1-parallel-runtime.run-object-characteristics">
  <h3 class="title">Internal Objects Notes</h3>
  <p class="para">
   Internal objects generally use a custom structure which cannot be copied by value safely, PHP currently lacks the mechanics to do this (without serialization) 
   and so only objects that do not use a custom structure may be shared.
  </p>
  <p class="para">
   Some internal objects do not use a custom structure, for example <span class="classname"><a href="class.parallel-events-event.html" class="classname">parallel\Events\Event</a></span> and so may be shared.
  </p>
  <p class="para">
   Closures are a special kind of internal object and support being copied by value, and so may be shared.
  </p>
  <p class="para">
   Channels are central to writing parallel code and support concurrent access and execution by necessity, and so may be shared.
  </p>
  <div class="warning"><strong class="warning">警告</strong>
   <p class="para">
    A user class that extends an internal class may use a custom structure as defined by the internal class, in which case they cannot be copied by value safely, 
    and so may not be shared.
   </p>
  </div>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-parallel-runtime.run-returnvalues">
  <h3 class="title">返回值</h3>
  <div class="warning"><strong class="warning">警告</strong>
   <p class="para">
    The return <span class="type"><a href="class.parallel-future.html" class="type parallel\Future">parallel\Future</a></span> must not be ignored when the task contains a return or throw statement.
   </p>
  </div>
 </div>


 <div class="refsect1 exceptions" id="refsect1-parallel-runtime.run-exceptions">
  <h3 class="title">Exceptions</h3>
  <div class="warning"><strong class="warning">警告</strong>
   <p class="para">
    Shall throw <span class="type"><span class="type parallel\Runtime\Error\Closed">parallel\Runtime\Error\Closed</span></span> if <span class="type"><a href="class.parallel-runtime.html" class="type parallel\Runtime">parallel\Runtime</a></span> was closed.
   </p>
  </div>
  <div class="warning"><strong class="warning">警告</strong>
   <p class="para">
    Shall throw <span class="type"><span class="type parallel\Runtime\Error\IllegalFunction">parallel\Runtime\Error\IllegalFunction</span></span> if <code class="parameter">task</code> is a closure created from an internal function.
   </p>
  </div>
  <div class="warning"><strong class="warning">警告</strong>
   <p class="para">
    Shall throw <span class="type"><span class="type parallel\Runtime\Error\IllegalInstruction">parallel\Runtime\Error\IllegalInstruction</span></span> if <code class="parameter">task</code> contains illegal instructions.
   </p>
  </div>
  <div class="warning"><strong class="warning">警告</strong>
   <p class="para">
    Shall throw <span class="type"><span class="type parallel\Runtime\Error\IllegalParameter">parallel\Runtime\Error\IllegalParameter</span></span> if <code class="parameter">task</code> accepts or <code class="parameter">argv</code> contains illegal variables.
   </p>
  </div>
  <div class="warning"><strong class="warning">警告</strong>
   <p class="para">
    Shall throw <span class="type"><span class="type parallel\Runtime\Error\IllegalReturn">parallel\Runtime\Error\IllegalReturn</span></span> if <code class="parameter">task</code> returns illegally.
   </p>
  </div>
 </div>


</div></div></div></body></html>